const {contextBridge,ipcRenderer} = require("electron")

function loginSuccess(params){
    ipcRenderer.send("login_success",params)
}


function saveData(data){
    ipcRenderer.send("save_content",data)
}
ipcRenderer.on("set_content",(event,data)=>{
    const app=document.getElementById("app")
    const textarea=document.createElement("textarea")
    textarea.id="app-textarea"
    textarea.style.border='none'
    textarea.style.outline="none"
    textarea.style.width='100%'
    textarea.style.height='100%'
    textarea.style.overflow='scroll'
    textarea.style.wordBreak='break-all'
    textarea.style.wordWrap='break-word'
    textarea.value=data
    app.setAttribute("contenteditable","true")
    app.style.border="none"
    app.style.outline="none"
    app.style.overflow='hidden'
    const body=window.document.body
    app.innerText=""
    app.append(textarea)
    app.style.fontSize=18+'px'
    body.append(app)
})

contextBridge.exposeInMainWorld("api",{
    env:process.env,
    loginSuccess,
    saveData
})